const Generator = require('yeoman-generator')

module.exports = class extends Generator {
    prompting() {
        return this.prompt([{
                type: 'input',
                name: 'name',
                message: 'Your project name',
                default: this.appname
            }])
            .then(answers => {
                this.answers = answers
            })
    }
    writing() {
        const templates = [
            '.browserslistrc',
            '.editorconfig',
            '.eslintrc.js',
            '.gitignore',
            'babel.config.js',
            'package.json',
            'package-lock.json',
            'README.md',
            'public/favicon.ico',
            'public/index.html',
            'src/App.vue',
            'src/main.js',
            'src/assets/logo.png',
            'src/components/HelloWorld.vue',
            'src/store/index.js',
            'src/store/mutations.js'
        ]
        templates.forEach(item => {
            // item 遍历每一个路径
            this.fs.copyTpl(
                this.templatePath(item),
                this.destinationPath(item)， this.answers
            )
        })
    }
}